package com.bj58.mis.bigdata.mdp.sys.controller;


import com.bj58.bsp.v2.user.vo.LoginUserBaseInfo;
import com.bj58.bsp.v2.utils.ServletLoginUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;

@RestController
public class IndexController {
    @Autowired
    protected RestTemplate restTemplate;

    @RequestMapping("")
    public String index(){
        return "hello spring boot demo";
    }

    @RequestMapping("/whoami")
    public LoginUserBaseInfo whoami(HttpServletRequest request){
        LoginUserBaseInfo loginUserBaseInfo = ServletLoginUtil.getLoginUser(request);
        return loginUserBaseInfo;
    }

    @RequestMapping("/info")
    public Object info(HttpServletRequest request){
        return restTemplate.getForObject("http://localhost:8888/actuator/info", String.class);
    }


}
